package cn.zyq.ykb.controller.mgt.pay;

import cn.zyq.ykb.beans.pay.PayOrder;
import cn.zyq.ykb.service.pay.PayOrderService;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付订单Controller
 *
 * @author SystemAuth
 * @date 2023-06-01
 */

@RestController(value = "MgtPayOrderController")
@RequestMapping("/mgt/payOrder")
@Api(tags = "支付订单接口")
public class PayOrderController extends BaseController {

    @Autowired
    private PayOrderService payOrderService;

    /**
     * 查询支付订单列表
     */
    @ApiOperation(value = "列表", response = PayOrder.class)
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:list')")
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.payOrderService.selectPayOrderList(pageParam);
    }

     /**
      * 导出支付订单列表
      */
     @ApiOperation(value = "导出")
     @PreAuthorize("@ss.hasPermi('ykb:payOrder:export')")
     @Log(title = "支付订单" , businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, PayOrder payOrder) {
         List<PayOrder> list = payOrderService.selectPayOrderList(payOrder);
         ExcelUtil<PayOrder> util = new ExcelUtil<PayOrder>(PayOrder. class);
         util.exportExcel(response, list, "支付订单数据");
     }

    /**
     * 获取支付订单详细信息
     */
    @ApiOperation(value = "详情", response = PayOrder.class)
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:query')")
    @GetMapping(value = "/{payOrderID}")
    public Object getInfo(@PathVariable("payOrderID") Integer payOrderID) {
        return this.payOrderService.selectPayOrderByPayOrderID(payOrderID);
    }
    /**
     * 获取支付订单详细信息
     */
    @ApiOperation(value = "详情", response = PayOrder.class)
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:query')")
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.payOrderService.detail(serviceID);
    }

    /**
     * 新增支付订单
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:add')")
    @Log(title = "支付订单", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody PayOrder payOrder) {
        return this.payOrderService.insertPayOrder(payOrder);
    }

    /**
     * 修改支付订单
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:edit')")
    @Log(title = "支付订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody PayOrder payOrder) {
        return this.payOrderService.updatePayOrder(payOrder);
    }

    /**
     * 删除支付订单
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('ykb:payOrder:remove')")
    @Log(title = "支付订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{payOrderIDs}")
    public Object remove(@PathVariable Integer[] payOrderIDs) {
        return this.payOrderService.deletePayOrderByPayOrderIDs(payOrderIDs);
    }
}
